#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    cin >> a[0];
    int pre = 0;
    for(int i = 1; i < n; i++) {
        cin >> a[i];
        int t = a[i], x = pre;
        int f = 0;
        while(t > a[i - 1]) {
            if(x == 0) {
                f = 1;
                break;
            }
            a[i - 1] *= 2;
            x--;
            pre--;
        }
        if(f) continue;
        while(t < a[i - 1]) {
            t *= 2;
            ans++;
            x++;
        }
        ans += pre;
        pre = x;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}